import React from 'react'
import Patent from './Patent'
import SoftwareWritings from './SoftwareWritings'
import Trademark from './Trademark'
import Certifications from './Certifications'
import RegistrationWebsite from './RegistrationWebsite'
import './style.less'

export interface IntellectualPropertyProps {
  companyCode: string
}

const IntellectualProperty: React.FC<IntellectualPropertyProps> = (props: IntellectualPropertyProps) => {
  const { companyCode } = props
  const [PatentCount, setPatentCount] = React.useState(0)
  const [SoftwareWritingsCount, setSoftwareWritingsCount] = React.useState(0)
  const [TrademarkCount, setTrademark] = React.useState(0)
  const [CertificationsCount, setCertificationsCount] = React.useState(0)
  const [RegistrationWebsiteCount, setRegistrationWebsiteCount] = React.useState(0)
  const setCount = () => {
    let counts: any = ''
    counts = PatentCount + SoftwareWritingsCount + TrademarkCount + CertificationsCount + RegistrationWebsiteCount
    return counts
  }

  return (
    <div className="company-detail-intellectual-property-wrapper" id="知识产权" data-count={setCount()}>
      <Patent companyCode={companyCode} hiddenModule={(e: any) => setPatentCount(e)} />
      <SoftwareWritings companyCode={companyCode} hiddenModule={(e: any) => setSoftwareWritingsCount(e)} />
      <Trademark companyCode={companyCode} hiddenModule={(e: any) => setTrademark(e)} />
      <Certifications companyCode={companyCode} hiddenModule={(e: any) => setCertificationsCount(e)} />
      <RegistrationWebsite companyCode={companyCode} hiddenModule={(e: any) => setRegistrationWebsiteCount(e)} />
    </div>
  )
}

export default IntellectualProperty
